/*
 * @Descripttion: 
 * @Author: chendingfengmail@163.com
 * @version: 
 * @Date: 2021-05-26 16:53:41
 * @LastEditors: chendingfengmail@163.com
 * @LastEditTime: 2022-01-11 11:34:03
 */
import util from '@/libs/util'

export default {
  install (Vue, options) {
    function writeLog (logType) {
      return (error, vm, info = '') => {
        Vue.nextTick(() => {
          if (process.env.NODE_ENV !== 'development') return
          util.log.capsule(`${process.env.VUE_APP_TITLE}`, 'ErrorHandler', logType)
          util.log.danger('>>>>>> 错误信息 >>>>>>')
          console.log(info)
          util.log.danger('>>>>>> Vue 实例 >>>>>>')
          console.log(vm)
          util.log.danger('>>>>>> Error >>>>>>')
          console.log(error)
        })
      }
    }
    if (process.env.NODE_ENV === 'development') {
      Vue.config.warnHandler = writeLog('warning')
    }
    Vue.config.errorHandler = writeLog('danger')
  }
}
